package com.ruoyi.gis.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.gis.service.IDatasetRasterTaskLineService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.gis.domain.DatasetRasterTaskNode;
import com.ruoyi.gis.service.IDatasetRasterTaskNodeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 任务节点Controller
 *
 * @author rww
 * @date 2024-09-21
 */
@RestController
@RequestMapping("/earthai/taskNode")
public class DatasetRasterTaskNodeController extends BaseController
{
    @Autowired
    private IDatasetRasterTaskNodeService datasetRasterTaskNodeService;
    /**
     * 查询任务节点列表
     */
    @PreAuthorize("@ss.hasPermi('earthai:taskNode:list')")
    @GetMapping("/list")
    public TableDataInfo list(DatasetRasterTaskNode datasetRasterTaskNode)
    {
        startPage();
        List<DatasetRasterTaskNode> list = datasetRasterTaskNodeService.selectDatasetRasterTaskNodeList(datasetRasterTaskNode);
        return getDataTable(list);
    }

    /**
     * 导出任务节点列表
     */
    @PreAuthorize("@ss.hasPermi('earthai:taskNode:export')")
    @Log(title = "任务节点", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DatasetRasterTaskNode datasetRasterTaskNode)
    {
        List<DatasetRasterTaskNode> list = datasetRasterTaskNodeService.selectDatasetRasterTaskNodeList(datasetRasterTaskNode);
        ExcelUtil<DatasetRasterTaskNode> util = new ExcelUtil<DatasetRasterTaskNode>(DatasetRasterTaskNode.class);
        util.exportExcel(response, list, "任务节点数据");
    }

    /**
     * 获取任务节点详细信息
     */
    @PreAuthorize("@ss.hasPermi('earthai:taskNode:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(datasetRasterTaskNodeService.selectDatasetRasterTaskNodeById(id));
    }

    /**
     * 新增任务节点
     */
    @PreAuthorize("@ss.hasPermi('earthai:taskNode:add')")
    @Log(title = "任务节点", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DatasetRasterTaskNode datasetRasterTaskNode)
    {
        return toAjax(datasetRasterTaskNodeService.insertDatasetRasterTaskNode(datasetRasterTaskNode));
    }

    /**
     * 修改任务节点
     */
    @PreAuthorize("@ss.hasPermi('earthai:taskNode:edit')")
    @Log(title = "任务节点", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DatasetRasterTaskNode datasetRasterTaskNode)
    {
        return toAjax(datasetRasterTaskNodeService.updateDatasetRasterTaskNode(datasetRasterTaskNode));
    }

    /**
     * 删除任务节点
     */
    @PreAuthorize("@ss.hasPermi('earthai:taskNode:remove')")
    @Log(title = "任务节点", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(datasetRasterTaskNodeService.deleteDatasetRasterTaskNodeByIds(ids));
    }
}
